package gateway.feign;

import common.config.feign.KeepErrMsgConfiguration;
import common.model.po.SysUser;
import common.model.request.SendEmailRequest;
import common.model.response.base.Result;
import gateway.feign.fallback.GatewayFeignFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 米泽鹏
 * @since 2022-3-23 下午 9:41
 */
@FeignClient(value = "system", fallbackFactory = GatewayFeignFallbackFactory.class, configuration = {KeepErrMsgConfiguration.class})
//@FeignClient(value = "system", fallbackFactory = GatewayFeignFallbackFactory.class, configuration = {NotBreakerConfiguration.class})
public interface SystemFeign {

	@RequestMapping(value = "/system/mail/sendEmail", method = RequestMethod.POST)
	Result<?> sendEmail(@RequestBody SendEmailRequest request);

	/**
	 * 样例方法（无参）
	 */
	@RequestMapping(value = "/system/sys-user/getAllUser", method = RequestMethod.GET)
	Result<List<SysUser>> getAllUser();

	/**
	 * 样例方法（使用@{@link RequestParam}传参）
	 */
	@RequestMapping(value = "/system/sys-user/deleteUserById", method = RequestMethod.DELETE)
	Result<SysUser> deleteUserById(@RequestParam("id") Integer id);

	/**
	 * 样例方法（使用@{@link PathVariable}传参）
	 */
	@RequestMapping(value = "/system/sys-user/getUserById/{id}", method = RequestMethod.POST)
	Result<SysUser> getUserById(@PathVariable("id") Integer id);

	/**
	 * 样例方法（使用@{@link RequestBody}传参）
	 */
	@RequestMapping(value = "/system/sys-user/addUser", method = RequestMethod.POST)
	Result<SysUser> addUser(@RequestBody SysUser user);

}
